package org.virbraligo.vboxjavaservice.gui.validator;

import java.io.File;

import javax.swing.JComponent;
import javax.swing.JTextField;

public class VBoxVMConfigurationValidator implements Validator{

	public String validate(JComponent comp) {
		String result = null;
		String vmconfig = ((JTextField) comp).getText().trim();
		File f = new File(vmconfig);
		String vmname = f.getName();
		//it's a .vbox file
		File vboxConfigFile = new File(f.getAbsolutePath()+"/"+vmname+".vbox");
		if(!vboxConfigFile.exists()){
			result = "VMConfiguration Path is not correct.";
		}
		return result;
	}

}
